import os

os.makedirs(os.path.join('../..', 'data'), exist_ok=True)
data_file = os.path.join('../..', 'data', 'house_tiny.csv')
print(data_file)
print(os.path.abspath(data_file))
with open(data_file, 'w') as f:
    f.write('NumRooms,Alley,Price\n')  # 列名
    f.write('NA,Pave,127500\n')  # 每行表示一个数据样本
    f.write('2,NA,106000\n')
    f.write('4,NA,178100\n')
    f.write('NA,NA,140000\n')

import pandas as pd

data = pd.read_csv(data_file)
print(data)
mean_value = data['NumRooms'].mean()
print(mean_value)

inputs_NumRooms = data['NumRooms'].fillna(mean_value)
inputs_Alley = pd.get_dummies(data['Alley'], dummy_na=True)
print(inputs_NumRooms)
print(inputs_Alley)
out_put = data.iloc[:, 2]
print(out_put)

import torch
X = torch.tensor(inputs_NumRooms.to_numpy(dtype=float)).reshape(4,1)
Y = torch.tensor(inputs_Alley.to_numpy(dtype=float))
print(X.shape)
print(Y.shape)
print(X*Y)
input_tensor = torch.cat((X, Y), dim=1)
print(input_tensor)
# Z = torch.arange(4).reshape(4,1)
# X_Z = torch.cat((X, Z), dim=1)
# print(X_Z)
# print("----------")
# print(Y)
# print(X_Z*Y)


